//
//  MYGPatientImageApi.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/4/29.
//

import UIKit
import Moya

enum MYGPatientImageApi {
    case uploadImages(patient_id:String,name:String,file:String)//上传随身影像
    case examinationList(patient_id:Int,sort:String)//随身影像列表 DESC/ ASC
    case examinationDetail(id:Int)//随身影像详情
    case shareExamination(params:[String:Any])//分享随身影像
    case myPatients(params:[String:Any])//随身影像-我的患者
    case deleteImageExamination(id:Int)//随身影像删除
    case renameImageExamination(id:String,name:String)//随身影像重命名
    case sendMsg(params:[String:Any])//随身影像重命名

}


extension MYGPatientImageApi: MYGTargetType {
    var path: String {
        switch self {
        case .sendMsg:
            "/api/image/send_sms"
        case .uploadImages:
            "api/image/examination"
        case .examinationList:
            "/api/image/examination"
        case .examinationDetail(let id):
            "/api/image/examination/\(id)"
        case .shareExamination:
            "/api/image/share/examination"
        case .myPatients:
            "/api/image/my_patients"
        case .deleteImageExamination(let id):
            "/api/image/examination/\(id)"
        case .renameImageExamination(let id,_):
            "/api/image/examination/\(id)"

        }
    }
    
    var params: [String : Any]{
        var params: [String : Any] = [:]
        switch self {
        case let .uploadImages(patient_id, name, file):
            params["patient_id"] = patient_id
            params["name"] = name
            params["file"] = file
        case let .examinationList(patient_id, sort):
            params["patient_id"] = patient_id
            params["sort"] = sort
        case .examinationDetail:
            break
        case let .sendMsg(params):
            return params
        case let .shareExamination(params):
           return params
        case let .myPatients(params):
            return params
        case .deleteImageExamination:
            return params
        case .renameImageExamination(_,let name):
            params["name"] = name
        }
   
        return params
    }
    
    var baseURL: URL{
        switch self {
        case .uploadImages,.examinationList,.examinationDetail,.shareExamination,.myPatients,.renameImageExamination,.deleteImageExamination,.sendMsg:
            return  URL(string: BaseUrl)!
        }
    }
    var method: Moya.Method {
        switch self {
        case .uploadImages,.shareExamination:
                .post
        case .examinationList,.examinationDetail,.myPatients,.sendMsg:
                .get
        case .deleteImageExamination:
                .delete
        case .renameImageExamination:
                .put
        }
        
    }
}
